--- a/src/mod/languages/mod_perl/Makefile.am
+++ b/src/mod/languages/mod_perl/Makefile.am
@@ -1,8 +1,5 @@
 include $(top_srcdir)/build/modmake.rulesam
 MODNAME=mod_perl
-PERL        = perl
-PERL_LIBDIR =-L`perl -MConfig -e 'print $$Config{archlib}'`/CORE
-PERL_LIBS   =`perl -MConfig -e 'print $$Config{libs}'`
 
 perldir=$(prefix)/perl
 mod_LTLIBRARIES = mod_perl.la
@@ -10,13 +7,13 @@ perl_LTLIBRARIES = freeswitch.la
 mod_perl_la_SOURCES  = mod_perl.c freeswitch_perl.cpp mod_perl_wrap.cpp perlxsi.c
 mod_perl_la_CFLAGS   = $(SWITCH_AM_CFLAGS)
 mod_perl_la_CXXFLAGS = $(SWITCH_AM_CXXFLAGS)
-mod_perl_la_CPPFLAGS = -w -DMULTIPLICITY `$(PERL) -MExtUtils::Embed -e ccopts` -DEMBED_PERL -I$(switch_srcdir)/libs/libteletone/src/ 
+mod_perl_la_CPPFLAGS = @PERL_CFLAGS@ -I$(switch_srcdir)/libs/libteletone/src/
 mod_perl_la_LIBADD   = $(switch_builddir)/libfreeswitch.la
-mod_perl_la_LDFLAGS  = -avoid-version -module -no-undefined -shared `$(PERL) -MExtUtils::Embed -e ldopts` `$(PERL) -MConfig -e 'print $$Config{libs}'`
+mod_perl_la_LDFLAGS  = -avoid-version -module -no-undefined -shared @PERL_LDFLAGS@ @PERL_LIBS@
 
 freeswitch_la_SOURCES = freeswitch_perl.cpp mod_perl_wrap.cpp perlxsi.c
 freeswitch_la_LDFLAGS = -avoid-version -module -no-undefined -shared $(LDFLAGS)
-freeswitch_la_CPPFLAGS = $(SWITCH_AM_CPPFLAGS) -w -DMULTIPLICITY `$(PERL) -MExtUtils::Embed -e ccopts` -DEMBED_PERL -I$(switch_srcdir)/libs/libteletone/src/ 
+freeswitch_la_CPPFLAGS = $(SWITCH_AM_CPPFLAGS) @PERL_CFLAGS@ -I$(switch_srcdir)/libs/libteletone/src/
 reswig:	swigclean mod_perl_wrap.cpp
 
 swigclean: clean
@@ -31,7 +28,7 @@ orig: mod_perl_wrap.cpp
 	patch -R -s -p0 -i hack.diff
 
 .perlok:
-	@(${PERL} -V | grep -i usemultiplicity=define >/dev/null && echo Phew, You have the right perl.) \
+	@(@PERL@ -V | grep -i usemultiplicity=define >/dev/null && echo Phew, You have the right perl.) \
 	|| ((echo Sorry, you need to compile perl with threads and multiplicity.&& exit 1))
 	@touch .perlok
 
